package tools

import "time"

//HalfAMonth 获取半个月后的时间，用于设置 session 有效期
func HalfAMonth() time.Time {
	nowTime := time.Now()
	later := nowTime.AddDate(0, 0, +15)
	//halfAMonthLater := later.Format("2006-01-02 15:04:05")
	return later
}

//GetHourDiffer 获取相差时间
func GetHourDiffer(startTime, endTime string) int64 {
	var hour int64
	t1, err := time.ParseInLocation("2006-01-02 15:04:05", startTime, time.Local)
	t2, err := time.ParseInLocation("2006-01-02 15:04:05", endTime, time.Local)
	if err == nil && t1.Before(t2) {
		diff := t2.Unix() - t1.Unix() //
		hour = diff / 3600
		return hour
	} else {
		return hour
	}
}
